<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ page
	import="com.onlineMIS.common.Common_util,java.util.Date,java.text.SimpleDateFormat"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>朴与素连锁店管理信息系统</title>
<%@ include file="../../common/Style.jsp"%>

<script>
$(document).ready(function(){
	$('#headqCustId').combobox('setValue', '-1');
	var yearId = $("#year").val();
	if (yearId <= 0)
	   $("#quarter").attr("disabled","true");
	$("#checkBrandBt").attr("disabled","true");
	parent.$.messager.progress('close'); 
	});
	

$(function(){
    $('#category').bind('click', function(){
    	generateReportByCategory()
    });
});

function generateReportByCategory(){
	if (validateReportForm()){
		$.messager.progress({
			title : '提示',
			text : '数据处理中，请稍后....'
		});
	    document.preGenReportForm.action="headqReportJSP!preGenerateHqSalesReportDetails?formBean.reportType=1";
	    document.preGenReportForm.submit();
	}
}

$(function(){
    $('#brand').bind('click', function(){
    	generateReportByBrand()
    });
});


function generateReportByBrand(){
	if (validateReportForm()){
		$.messager.progress({
			title : '提示',
			text : '数据处理中，请稍后....'
		});
	    document.preGenReportForm.action="headqReportJSP!preGenerateHqSalesReportDetails?formBean.reportType=0";
	    document.preGenReportForm.submit();
	}
	
}

/**
 * 表单校验
 */
function validateReportForm(){
	var barcode = $("#barcode").textbox('getValue');
	if(barcode != null && barcode != ""){
		if(barcode.length == 12 && barcode == parseInt(barcode)){
			return true;
		}else{
			$.messager.alert('提示','非法条码字符,请重新输入条码!','warning');
		}
	}else{
		return true;
	}
	


}
</script>
</head>
<body>
	<s:form id="preGenReportForm" name="preGenReportForm"
		action="/action/headqReportJSP!preGenerateHqSalesReportDetails"
		theme="simple" method="POST">
		<table width="60%" align="center" class="OuterTable">
			<tr>
				<td>
					<table width="100%" border="0">
						<tr>
							<td height="50" colspan="7">
								<table width="100%" border="0" cellpadding="0" cellspacing="0">
									<tr class="PBAOuterTableTitale">
										<td height="43" colspan="3">总部销售统计报表</td>
									</tr>
									<tr class="InnerTableContent">
										<td height="32" colspan="3"><s:actionerror
												cssStyle="color:red" />
											<s:actionmessage cssStyle="color:blue" /></td>
									</tr>
									<tr class="InnerTableContent">
										<td height="32"><strong>单据过账日期</strong></td>
										<td colspan="2"><s:textfield id="startDate"
												name="formBean.startDate" cssClass="easyui-datebox"
												data-options="width:100,editable:false" /> &nbsp;至&nbsp; <s:textfield
												id="endDate" name="formBean.endDate"
												cssClass="easyui-datebox"
												data-options="width:100,editable:false" /></td>
									</tr>
									<tr class="InnerTableContent">
										<td height="32"><strong>客户</strong></td>
										<td colspan="2">
											<s:select size="1" cssClass="easyui-combobox"  style="width:30%" data-options="prompt:'请选择客户'"   id="headqCustId" list="uiBean.custs" listKey="id" name="formBean.cust.id" listValue="name" />
										</td>
									</tr>
									<tr class="InnerTableContent">
										<td height="32"><strong>货品归属</strong></td>
										<td colspan="2">
											<s:select size="1" cssClass="easyui-combobox"  style="width:30%" data-options="prompt:'请选择归属'"   id="belongTo" list="uiBean.belongToVOs" listKey="id" name="formBean.belongTo" listValue="belongToName" />
										</td>
									</tr>
									<tr class="InnerTableContent">
										<td height="32"><strong>条码</strong></td>
										<td colspan="2">
											<s:textfield id="barcode"  style="width:30%" cssClass="easyui-textbox" data-options="prompt:'请输入货品条码'" name="formBean.barcode" size="12" />
										</td>
									</tr>
									<tr class="InnerTableContent">
										<td height="34">&nbsp;</td>									
										<td colspan="2"><a id="brand" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'">查询品牌报表</a><a id="category" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'">查询类别报表</a></td>					      											
									</tr>
								</table>
							</td>
						</tr>
					</table>
				</td>
			</tr>

		</table>
	</s:form>
</body>
</html>